﻿using System;
using System.Collections;
using System.Collections.Generic;
using U3dUtils;
using UI00;
using UnityEngine.UI;
namespace G12 {
    public class UI_Setup : UIBase {
        protected override string _GetUIPrefabPath() {
            return "Assets/ImgPreview/ResourcesAB/ImgPreview/UI/UI_Setup/UI_Setup.prefab";
        }

        Button clearButton, AgreeButton;
        Slider screenCardNumberSlider, selectCardMaxNumberSlider, selectRadiusZoomRatioSlider;
        Text screenCardNumberSliderExplain, selectCardMaxNumberSliderExplain, selectRadiusZoomRatioSliderExplain;
        CToggle isShowAssetsPathToggle, videoIsAllPlayToggle;

        protected override void _Init() {
            screenCardNumberSlider = GetControl<Slider>("view/screenCardNumberSlider");
            selectCardMaxNumberSlider = GetControl<Slider>("view/selectCardMaxNumberSlider");
            selectRadiusZoomRatioSlider = GetControl<Slider>("view/selectRadiusZoomRatioSlider");
            clearButton = GetControl<Button>("view/clearButton");
            AgreeButton = GetControl<Button>("view/AgreeButton");
            screenCardNumberSliderExplain = GetControl<Text>("explain", screenCardNumberSlider);
            selectCardMaxNumberSliderExplain = GetControl<Text>("explain", selectCardMaxNumberSlider);
            selectRadiusZoomRatioSliderExplain = GetControl<Text>("explain", selectRadiusZoomRatioSlider);
            isShowAssetsPathToggle = GetControl<CToggle>("view/isShowAssetsPathToggle");
            videoIsAllPlayToggle = GetControl<CToggle>("view/videoIsAllPlayToggle");
            screenCardNumberSlider.onValueChanged.AddListener(delegate(float ff) {
                int value = ((int)ff);
                screenCardNumberSliderExplain.text = "屏幕照片数量 " + value;
                //  C_Parameter.screenCardNumber = value;
            });
            selectCardMaxNumberSlider.onValueChanged.AddListener(delegate(float ff) {
                int value = ((int)ff);
                selectCardMaxNumberSliderExplain.text = "能选中的照片最大数量  " + value;
                UI_Main.CParameter.selectCardMaxNumber.value = value;
            });
            selectRadiusZoomRatioSlider.onValueChanged.AddListener(delegate(float ff) {
                int value = ((int)ff);
                selectRadiusZoomRatioSliderExplain.text = "选中泡泡半径放大的倍数  " + value;
                UI_Main.CParameter.selectRadiusZoomRatio.value = value;
            });
            clearButton.onClick.AddListener(delegate() {
                Close();
            });
            AgreeButton.onClick.AddListener(delegate() {
                Close();
                G12Manage.instance.uiMain.StartRun();
            });
            isShowAssetsPathToggle.onSelectEvent += delegate(CToggle nn) {
                UI_Main.CParameter.isShowAssetsPath.value = nn.isSelected ? 1 : 0;
            };
            videoIsAllPlayToggle.onSelectEvent += delegate(CToggle nn) {
                UI_Main.CParameter.videoIsAllPlay.value = nn.isSelected ? 1 : 0;
                SystemTipsUI.TipsView2("切换视频播放模式", "需要重新加载场景", delegate(bool isConfirm) {
                    if (isConfirm) {
                        Close();
                        G12Manage.instance.uiMain.StartRun();
                    }
                });
            };
        }

        protected override void _Open(Dictionary<string, object> paraDic) {
            S_RefreshShow();
        }

        void S_RefreshShow() {
            // screenCardNumberSlider.value= C_Parameter.screenCardNumber;
            selectCardMaxNumberSlider.value = UI_Main.CParameter.selectCardMaxNumber.value;
            selectRadiusZoomRatioSlider.value = (float)UI_Main.CParameter.selectRadiusZoomRatio.value;
            isShowAssetsPathToggle.isSelected = UI_Main.CParameter.isShowAssetsPath.value == 1;
            videoIsAllPlayToggle.isSelected = UI_Main.CParameter.videoIsAllPlay.value == 1;
        }
    }
}
